//
//  WBBaseViewController.swift
//  weibo
//
//  Created by apple on 2017/5/17.
//  Copyright © 2017年 hbjApple. All rights reserved.
//

import UIKit
class WBBaseViewController: UIViewController {
    ///自定义导航条
    lazy var navBar = UINavigationBar(frame: CGRect(x:0,y:0,width:UIScreen.main.bounds.width,height:64))
    var tableView: UITableView?

    //自定义的导航目
    lazy var navItem = UINavigationItem()
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
      

        // Do any additional setup after loading the view.
    }
    //重写title 的didset
    override var title: String?{
        didSet {
        navItem.title = title
        }
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
//MARK:设置界面
extension WBBaseViewController {
     func setupUI() {
        view.backgroundColor = UIColor.orange
        //添加导航条
        view.addSubview(navBar)
        //将item设置给bar
        navBar.items = [navItem]
        setupTbaleView()
    }
  private   func setupTbaleView(){
       tableView = UITableView(frame: view.bounds, style: .plain)
        tableView?.delegate = self
        tableView?.dataSource = self
        view.insertSubview(tableView!, belowSubview: navBar)
    }
}
//MARK:设置tableview delegate 
/// Type 'WBBaseViewController' does not conform to protocol 'UITableViewDataSource'
extension WBBaseViewController: UITableViewDelegate,UITableViewDataSource{
    func numberOfSections(in tableView: UITableView) -> Int {
        return 0
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
      return 0
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        return UITableViewCell()
    }
}
